﻿<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>会员注册</title>

<link rel="stylesheet" href="css/style.css">

</head>
<body>

<div class="container">
	<div class="header">
		<h2>注册会员</h2>
	</div>
	<form id="form" class="form">
		<div class="form-control">
			<label for="username">用户名</label>
			<input type="text" placeholder="用户名" name="username" id="username" />
			<i class="fas fa-check-circle"></i>
			<i class="fas fa-exclamation-circle"></i>
			<small>Error message</small>
		</div>
		<div class="form-control">
			<label for="password">密码</label>
			<input type="password" placeholder="密码" name="password" id="password">
			<i class="fas fa-check-circle"></i>
			<i class="fas fa-exclamation-circle"></i>
			<small>Error message</small>
		</div>
		<button onclick="register()">提交</button>
	</form>
</div>

<script src="js/script.js"></script>
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
        function register() {
        	var username = $("#username").val();
        	var password = $("#password").val();
        	alert(username)
            $.ajax({
            //几个参数需要注意一下
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "http://127.0.0.1:8082/api/user/add_user/" ,//url
                contenType:"application/json",
                data: $('#form').serialize(),
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    if (result.status == "ok") {
                        alert("即将开启，推广返利10%	");
                    }
                    ;
                },
                error : function() {
                    console.log($('#form').serialize());
                    alert("异常！");
                }
            });
        }
    </script>
</body>
</html>